package pt.mauromad.guias.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/manifest/{manifest:[0-9]+}/manifest-item")
public class ManifestItemController extends BaseController {
//	@RequestMapping(value = "/{item:[0-9]+}", method = RequestMethod.GET)
//	public String newItem(Model model, @PathVariable ManifestItemDao item) {
//		model.addAttribute("item", Item2Bean.get(item));
//		model.addAttribute("action", "edit");
//		return "manifest-items/manifest-item-form";
//	}
//
//	/**
//	 * redirect any action in the form
//	 * 
//	 * @param manifest
//	 * @param action
//	 * @return
//	 */
//	@RequestMapping(value = "/{item:[0-9]+}", method = RequestMethod.POST)
//	public String postAction(@PathVariable Long manifest, @PathVariable Long item, @RequestParam String action) {
//		return String.format("redirect:/manifest/%s/manifest-item/%s/%s", manifest, item, action);
//	}
//
//	@RequestMapping(value = "/new", method = RequestMethod.GET)
//	public String newItem(Model model) {
//		model.addAttribute("editable", true);
//		model.addAttribute("action", "save");
//		return "manifest-items/manifest-item-form";
//	}
//
//	@RequestMapping(value = "/new", method = RequestMethod.POST, params = { "action=save" })
//	public String saveNewItem(Model model, @Validated ItemBean item, @PathVariable ManifestDao manifest) {
//		ManifestItemDao itemDao = Item2Dao.get(item);
//		itemDao.setManifest(manifest);
//		itemService.save(itemDao);
//		return String.format("redirect:/manifest/%s", manifest.getId());
//	}
//
//	@RequestMapping(value = "/{item:[0-9]+}/edit", method = RequestMethod.GET)
//	public String saveNewItem(Model model, @PathVariable ManifestItemDao item) {
//		model.addAttribute("item", Item2Bean.get(item));
//		model.addAttribute("editable", true);
//		model.addAttribute("action", "save");
//
//		return "manifest-items/manifest-item-form";
//	}
//
//	@RequestMapping(value = "/{itemId:[0-9]+}/edit", method = RequestMethod.POST)
//	public String saveNewItem(Model model, @PathVariable Long itemId, @Validated ItemBean itemBean, @PathVariable Long manifest) {
//		itemBean.setManifestId(manifest);
//		itemBean.setId(itemId);
//		itemService.save(Item2Dao.get(itemBean));
//		return format("redirect:/manifest/%s/edit", manifest);
//	}
}
